package com.msmall.community.bbs.service;

import java.util.List;

import com.msmall.base.exception.AuthorityException;
import com.msmall.base.exception.DataNotFoundException;
import com.msmall.base.pager.PaginationSupport;
import com.msmall.base.service.BaseManager;
import com.msmall.community.bbs.model.Thread;
import com.msmall.community.bbs.model.Topic;


public interface TopicManager extends BaseManager<Topic, Long>{

	/**
	 * 
	 * @param topic
	 * @description 发帖
	 * @return 1标题字符太少 2标题字符太多 3标题有非法字符 4内容字符太少 5内容字符太多 6内容有非法字符 7正常
	 */
	public Topic saveTopic(Topic topic, Long boardId, Long userid, String userAgentType);
	/**
	 * 此方法保存的TOPIC 不能访问 enabled = constantdb.unavaliable
	 * 目前只有创建TeamTopic时使用
	 */
	public Topic saveTopicDisabled(Topic topic, Long boardId, Long userid, String userAgentType);
	/**
	 * 获得某主题帖的跟帖分页
	 * @param page
	 * @param userid 当前登录系统的用户，用于分页的PAGESIZE
	 * @param topicId 主题帖ID
	 * @param who 只显示who的回复，用于只关注谁,当为null时，查询所有的
	 */
	public void getThreadPaginationByTopic(PaginationSupport page, Long userid, Long topicId, Long who);
	
	
	/**
	 * 点击时，添加阅读数量
	 * @param topicId
	 */
	public void addClickAmount(Long topicId);
	public void addClickAmount(Topic topic);
	
	/**
	 * 回复时，添加回复数量
	 * @param topicId
	 
	public void addThreadAmount(Long topicId);
	public void addThreadAmount(Topic topic);
	*/
	/**
	 * 查看某个用户对某个主题帖的所有回复
	 * @param userid
	 */
	public List<Thread> viewUserOnly(Long topicId, Long userid);
	
	/**
	 * 获得userid发表的所以主题帖
	 * @param page
	 * @param userid
	 */
	public void getPaginationbyUserid(PaginationSupport page, Long userid);
	
	/**
	 * 删除帖子
	 * @param topicId
	 * @throws AuthorityException 
	 */
	public void delete(Long topicId, Long userid) throws AuthorityException;
	
	/**
	 * userid将topicid加精
	 * @param topicId
	 * @param userid
	 * @throws DataNotFoundException 
	 * @throws AuthorityException 
	 */
	public void setElite(Long topicId, Long userid) throws DataNotFoundException, AuthorityException;

	/**
	 * userid将topicid删除加精
	 * @param topicId
	 * @param userid
	 * @throws DataNotFoundException 
	 * @throws AuthorityException 
	 */
	public void deleteElite(Long topicId, Long userid) throws DataNotFoundException, AuthorityException;
	
	/**
	 * userid将topicid置顶
	 * @param topicId
	 * @param userid
	 * @throws DataNotFoundException 
	 * @throws AuthorityException 
	 */
	public void setTop(Long topicId, Long userid) throws DataNotFoundException, AuthorityException;
	
	/**
	 * userid将topicid删除置顶
	 * @param topicId
	 * @param userid
	 * @throws DataNotFoundException 
	 * @throws AuthorityException 
	 */
	public void deleteTop(Long topicId, Long userid) throws DataNotFoundException, AuthorityException;
	
	/**
	 * userid将topicid推荐
	 * @param topicId
	 * @param userid
	 * @throws DataNotFoundException 
	 * @throws AuthorityException 
	 */
	public void setCommend(Long topicId, Long userid) throws DataNotFoundException, AuthorityException;
	
	/**
	 * userid将topicid删除推荐
	 * @param topicId
	 * @param userid
	 * @throws DataNotFoundException 
	 * @throws AuthorityException 
	 */
	public void deleteCommend(Long topicId, Long userid) throws DataNotFoundException, AuthorityException;
	
	/**
	 * 获得TOPIC，将文件内容读取存入TOPIC
	 * @param topicId
	 * @throws DataNotFoundException
	 * @throws AuthorityException
	 */
	public Topic getTopic(Long topicId) throws DataNotFoundException, AuthorityException;
	
	/**
	 * 更新TOPIC，修改原文件
	 * @param topicId
	 * @throws DataNotFoundException
	 * @throws AuthorityException
	 */
	public void updateTopic(Topic topic, Long userid, String uat) throws DataNotFoundException, AuthorityException;
	
	/**
	 *从缓存取得所有版区的前50个点击率最高的帖子，并且是当天发布的，
	 */
	public List<Topic> hotTopic(int amount);
	
	/**
	 * 所有版区的前50个点击率最高的帖子，并且是当天发布的，放入缓存
	 */
	public List<Topic> initHotTopic();
	
	/**
	 * 验证TOPIC TITLE
	 * @return 1:正常；2字符太少；3字符太多;4含有非法字符
	 */
	public int validateTopicTitle(String title);
	
	/**
	 * 验证TOPIC content
	 * @return 1:正常；2字符太少；3字符太多;4含有非法字符
	 */
	public int validateTopicContent(String content);
}
